import request from "../../request/request";

// 登录
export function Login(data) {
    return request({
        url: '/admin/system/index/login',
        method: 'post',
        // headers:{'Content-Type':'application/x-www-form-urlencoded'},
        data
    })
}




// 获取登录用户信息
export function GetUserinfo() {
    return request({
        url: '/admin/system/index/getUserInfo',
        method: 'get'
    });
}

// 获取验证码
export function GetValidateCode() {
    return request({
        url: '/admin/system/index/generateValidateCode',
        method: 'get'
    });
}

// 退出功能
export function Logout() {
    return request({
        url: '/admin/system/index/logout',
        method: 'get'
    });
}

// 获取菜单
export function GetMenus() {
    return request({
        url: '/admin/menu/getMenu',
        method: 'get',
        headers: {
            'token': localStorage.getItem('token')
        },
        retry: 2,
        retryDelay: 500000
    })
}






// 展示所有ad用户
export function adUserList(data) {
    return request({
        url: '/admin/user/adUserList',
        method: 'post',
        // headers:{'Content-Type':'application/x-www-form-urlencoded'},
        data
    })
}
// 展示所有ad用户
export function adUserStatus(id, status) {
    return request({
        url: '/admin/user/adUserStatus',
        method: 'post',
        // headers:{'Content-Type':'application/x-www-form-urlencoded'},
        params: {
            id: id,
            status: status
        }
    })
}
// 展示删除用户信息
export function adUserDelete(id) {
    return request({
        url: '/admin/user/adUserDelete',
        method: 'post',
        // headers:{'Content-Type':'application/x-www-form-urlencoded'},
        params: {
            id: id
        }
    })
}
// 展示添加ad用户
export function adUserAddOrUpdate(data) {
    return request({
        url: '/admin/user/adUserAddOrUpdate',
        method: 'post',
        //headers:{'Content-Type':'application/x-www-form-urlencoded'},
        data
    })
}














// 免登录
export function freeLogin() {
    return request({
        url: '/user/freeLogin',
        method: 'get',
    })
}

// 退出登录
export function logout() {
    return request({
        url: '/logout',
        method: 'post'
    })
}

// 获取当前用户信息
export function getUserInfo() {
    return request({
        url: '/user/getUserInfo',
        method: 'get'
    })
}

// 获取所有用户信息
export function selectUser(data) {
    return request({
        url: '/user/userList',
        method: 'post',
        data
    })
}

// 获取所有用户信息
export function delUser(ids) {
    return request({
        url: '/user/delUser/' + ids,
        method: 'get',

    })
}


export function delOneUser(id) {
    return request({
        url: '/user/delOneUser/' + id,
        method: 'get',

    })
}

//新增
export function addUser(data) {
    return request({
        url: '/user/addUser',
        method: 'post',
        data
    })
}

//修改
export function updateUser(data) {
    return request({
        url: '/user/addUser',
        method: 'post',
        data
    })
}

//根据id获取用户信息
export function getUserById(id) {
    return request({
        url: '/user/getUserById/' + id,
        method: 'get'
    })
}

//根据id获取用户对应角色信息
export function getUserAndRole(id) {
    return request({
        url: '/user/getUserAndRole/' + id,
        method: 'get'
    })
}

// 获取用户信息
export function findAllUser() {
    return request({
        url: '/user/findAllUser',
        method: 'get'
    })
}

// 更换头像
export function updateAvatar(data) {
    return request({
        url: '/user/updateAvatar',
        method: 'post',
        data
    })
}

//回显当前用户信息
export function showUserInfo() {
    return request({
        url: '/user/showUserInfo',
        method: 'get'
    })
}

//修改当前登录用户信息
export function updateUserInfo(data) {
    return request({
        url: '/user/updateUserInfo',
        method: 'post',
        data
    })
}

// 获取首页统计数据
export function getStatistics() {
    return request({
        url: '/statistics/overview',
        method: 'get'
    })
}

// 获取用户类型占比数据
export function getUserRatio() {
    return request({
        url: '/statistics/userRatio',
        method: 'get'
    })
}

// 获取用户增长数据
export function getUserGrowth() {
    return request({
        url: '/statistics/userGrowth',
        method: 'get'
    })
}
